package com.cubeofnine.sugar.service.element;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class Email implements KvmSerializable {
	private String email_type;
	private String email_value;

	public Email() {
		super();
	}

	public Email(String email_type, String email_value) {
		super();
		this.email_type = email_type;
		this.email_value = email_value;
	}

	public Email(SoapObject obj) {
		super();
		try {
			this.email_type = obj.getProperty("email_type").toString();
		} catch (Exception e) {
			this.email_type = null;
		}

		try {
			this.email_value = obj.getProperty("email_value").toString();
		} catch (Exception e) {
			this.email_value = null;
		}
	}

	public Object getProperty(int index) {
		Object object = null;

		switch (index) {
		case 0:
			object = this.email_type;
			break;
		case 1:
			object = this.email_value;
			break;
		}

		return object;
	}

	public int getPropertyCount() {
		return 2;// Count GloVariable
	}

	public void getPropertyInfo(int index, Hashtable arg1,
			PropertyInfo propertyInfo) {
		switch (index) {
		case 0:
			propertyInfo.name = "email_type";
			propertyInfo.type = PropertyInfo.STRING_CLASS;
			break;
		case 1:
			propertyInfo.name = "email_value";
			propertyInfo.type = PropertyInfo.STRING_CLASS;
			break;
		}
	}

	public void setProperty(int index, Object obj) {
		switch (index) {
		case 0:
			this.email_type = obj.toString();
			break;
		case 1:
			this.email_value = obj.toString();
			break;
		}
	}

	public String getEmail_type() {
		return email_type;
	}

	public void setEmail_type(String email_type) {
		this.email_type = email_type;
	}

	public String getEmail_value() {
		return email_value;
	}

	public void setEmail_value(String email_value) {
		this.email_value = email_value;
	}

	@Override
	public String toString() {
		return "Email [email_type=" + email_type + ", email_value="
				+ email_value + "]";
	}

}
